//
//  ViewController.swift
//  Demo-10 自定义手势+指定区域识别触摸
//
//  Created by quanhao huang on 2019/9/30.
//  Copyright © 2019 demo. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var customGestureLabel: UILabel!
    @IBOutlet weak var customGestureView: UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //使用自定义手势
        let downUpGesture = DownUpGestureRecognizer(target: self, action: #selector(downUp(downUpGesture:)))
        self.customGestureView.addGestureRecognizer(downUpGesture)
    }
    
    @objc func downUp(downUpGesture :DownUpGestureRecognizer) {
        switch downUpGesture.state {
        case .began:
            self.customGestureLabel.text = "Gesture began"
            break
        case .changed:
            self.customGestureLabel.text = "Gesture changed"
            break
        case .ended:
            self.customGestureLabel.text = "Gesture ended"
            break
        case .cancelled:
            self.customGestureLabel.text = "Gesture cancelled"
            break
        case .possible:
            self.customGestureLabel.text = "Gesture possible"
            break
        case .failed:
            self.customGestureLabel.text = "Gesture failed"
            break
        default:
            break
        }
        
        
        //如果要在指定的区域识别手势需要覆盖pointInside(_,withEvent:)方法
        
        //在UIView子类中覆盖(testView.swift)
    }

}

